package models

import (
	"tms-server/driver"
	"tms-server/env"
)

type Dep struct {
	Id      int64  `xorm:"pk autoincr int(11)"`
	Type    string `xorm:"varchar(50)"`
	Name    string `xorm:"varchar(50)"`
	Level   int    `xorm:"int(11)"`
	Contact string `xorm:"varchar(50)"`
	Addr    string `xorm:"varchar(50)"`
	Tel     string `xorm:"varchar(50)"`
	Ver     int    `xorm:"version"`
}

func FindDep(id int64) (dep *Dep, err error) {
	dep = new(Dep)
	dep.Id = id
	found, err := driver.X.Get(dep)
	if err != nil {
		return nil, err
	}
	if !found {
		return nil, env.NotFound
	}
	return
}
